package com.webwork.mood.common.dao.impl;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.LinkedHashMap;

/**
 * 单表DAO实现<br>
 * 
 */
public abstract class SimpleDao extends CommonDBDao {

	/**
	 * 表名
	 * 
	 * @return
	 */
	protected String dbTable = "";

	/**
	 * 各字段名映射<br>
	 * object property name -map-> database column name
	 * 
	 * @return
	 */
	protected LinkedHashMap<String, String> dbColumns = new LinkedHashMap<String, String>();

	public String getDbTable() {
		return dbTable;
	}

	public LinkedHashMap<String, String> getDbColumns() {
		return this.dbColumns;
	}

	/**
	 * 获得时间戳字段毫秒
	 * 
	 * @param rs ResultSet
	 * @param dbColumn 字段
	 * @return
	 * @throws SQLException
	 */
	protected Long getTimestamp(ResultSet rs, String dbColumn) throws SQLException {
		Timestamp ret;
		if ((ret = rs.getTimestamp(dbColumn)) == null) {
			return null;
		}
		return ret.getTime();
	}

}
